package cn.xique.module.weixin.web.payment;

import cn.xique.module.weixin.web.IbeanBaseController;
import com.jfinal.core.paragetter.Para;
import com.jfinal.kit.PropKit;
import com.jfinal.kit.Ret;
import com.jfinal.weixin.sdk.api.RedPackApi;

import java.util.Map;

public class RedPackApiController extends IbeanBaseController {

    /**
     * 发送普通红包
     */
    public void sendredpack() {
        Map params = this.getParaMap();
        String cerPath = PropKit.use("boot_properies").get("cerPath");
        String cerpasswd = PropKit.use("boot_properies").get("cerpasswd");
       String apiResult =  RedPackApi.sendRedPack(params, cerPath, cerpasswd);

        renderJson(Ret.ok().set("success", true).set("result", apiResult));
    }


    /**
     * 发送裂变红包
     */
    public void sendGroupRedPack( ) {

        Map params = this.getParaMap();
        String cerPath = PropKit.use("boot_properies").get("cerPath");
        String cerpasswd = PropKit.use("boot_properies").get("cerpasswd");
        String apiResult =  RedPackApi.sendGroupRedPack(params, cerPath, cerpasswd);

        renderJson(Ret.ok().set("success", true).set("result", apiResult));

    }

    /**
     * 查询红包记录
     */
    public void query() {
        Map params = this.getParaMap();
        String cerPath = PropKit.use("boot_properies").get("cerPath");
        String cerpasswd = PropKit.use("boot_properies").get("cerpasswd");
        String apiResult = RedPackApi.getHbInfo(params, cerPath, cerpasswd);
        renderJson(Ret.ok().set("success", true).set("result", apiResult));
    }



}
